﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DA
{
    public class DonHangMoiDA:BaseConnection
    {
        public SqlDataAdapter donHangMoiAdapter { set; get; }
        public DonHangMoiDA()
        {
            
        }
        public int taoDonHangMoi(string maDonHang, string maKhachHang, string diaChi, string ngayNhan, string ngayGiao)
        {
            String sqlStm = "INSERT INTO ThongTinDonHang(MaDonHang, MaKhachHang, DiaChi, NgayNhan, NgayGiao) VALUES(@maDonHang, @maKhachHang, @diaChi, @ngayNhan, @ngayGiao)";
            openConnect();
            SqlCommand cmd = new SqlCommand(sqlStm, con);
            cmd.Parameters.Add("@maDonHang", SqlDbType.VarChar).Value = maDonHang;
            cmd.Parameters.Add("@maKhachHang", SqlDbType.VarChar).Value = maKhachHang;
            cmd.Parameters.Add("@diaChi", SqlDbType.NVarChar).Value = diaChi;
            cmd.Parameters.Add("@ngayNhan", SqlDbType.DateTime).Value = DateTime.Parse(ngayNhan);
            cmd.Parameters.Add("@ngayGiao", SqlDbType.DateTime).Value = DateTime.Parse(ngayGiao);
            return cmd.ExecuteNonQuery();
        }

    }

}
